package qq.android.wan.qq.recever;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import qq.android.wan.qq.utils.IntentUtil;

/**
 * Created by mac on 2016/3/8.
 */
public class NetChangeRecever extends BroadcastReceiver {
    private LinearLayout layout_net;

    public NetChangeRecever(LinearLayout layout_net) {
        this.layout_net = layout_net;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        boolean isConnect=new IntentUtil().isConnectionNet(context);
        if(layout_net==null){
            return;
        }
        if(isConnect){
            layout_net.setVisibility(View.GONE);
        }else{
            layout_net.setVisibility(View.VISIBLE);
            Toast.makeText(context,"网络连接不可用",Toast.LENGTH_SHORT).show();
        }
    }
}
